﻿// ===============================================================================
// DotNet.Platform 开发框架 2016 版权所有
// ===============================================================================

using System.Threading.Tasks;

namespace XNWebService
{
    /// <summary>
    /// 火车时刻查询
    /// </summary>
    public class TrainService
    {
        /// <summary>
        /// 火车时刻查询
        /// </summary>
        /// <param name="from">出发站（如：上海虹桥）</param>
        /// <param name="to">到达站（如：温州南）</param>
        /// <param name="date">出发日期，格式（yyyy-MM-dd，如：2016-05-01）</param>
        /// <returns>返回结果Json字符串</returns>
        public static async Task<string> TrainSearch(string from, string to, string date)
        {
            var client = API.HttpClient;
            var url = "http://apis.haoservice.com/lifeservice/train/ypcx?key=fc425353940048d0934720944716f638";
            var param = $"&date={date}&from={from}&to={to}";
            return await client.GetStringAsync(url + param);
        }
    }
}